<script>
function initialCap(field) {
   field.value = field.value.substr(0, 1).toUpperCase() + field.value.substr(1);
}
	</script>
<?php $data=json_decode($this->option['smtp_options'],true); ?>
    <div id="main">
      <div class="w950 mc bg_table po p15b">
        <div class="top_left"></div>
        <div class="top_right"></div>
        <div class="bottom_left"></div>
        <div class="bottom_right"></div>
        <h3 class="p15t p15l p15b bg_bot"><b><?php echo $this->translate->_("Email setting");?></b></h3>
        <div class="w920 mc p15t">
            <?php if($this->msg){?>
      <br />
      <span style="font-size-adjust: 15px; color: red;"><?php echo $this->msg;?></span>
      <?php }?>
<form id="data-form" onsubmit="return batteryObj.validateForm('data-form');" method="post" enctype="multipart/form-data">
       	  <div class="w445 float_left">
          <label class="lbl1"><?php echo $this->translate->_("SMTP Host");?>:<em> *</em></label>
          
	  <input name="data[smtpHost]" value="<?php echo $data['smtpHost']; ?>" class="txt1 required" type="text" />
          <br class="clear" />
          <label class="lbl1"><?php echo $this->translate->_("SMTP Port");?>:<em> *</em></label>
	  <input name="data[smtpPort]" value="<?php echo $data['smtpPort']; ?>" class="txt1 required" type="text" />
          <br class="clear" />
          <label class="lbl1"><?php echo $this->translate->_("Encryption");?>:</label>
            <div class="float_left w200 p10b po1">
            <input name="data[smtpSsl]" type="radio" value="no"
            <?php echo $data['smtpSsl'] == 'no' ? 'checked' : ''; ?>
                   <?php echo!$data['smtpSsl'] ? 'checked' : ''; ?> /> <?php echo $this->translate->_("No encryption");?>
            <br>
            <input name="data[smtpSsl]" type="radio" value="ssl"
                   <?php echo $data['smtpSsl'] == 'ssl' ? 'checked' : ''; ?>  /> <?php echo $this->translate->_("Use SSL encryption");?>
            <br>
            <input name="data[smtpSsl]" type="radio" value="tls"
                   <?php echo $data['smtpSsl'] == 'tls' ? 'checked' : ''; ?>  /> <?php echo $this->translate->_("Use TLS encryption");?>
            </div>
            <br style="clear:left;">

          <label class="lbl1"><?php echo $this->translate->_("Authentication");?>:</label>
            <div class="float_left p10b po1">
            <input type="radio" name="data[smtpAuthentication]" value="0" class="smtpAuthen"
                   <?php echo $data['smtpAuthentication'] == '0' ? 'checked' : ''; ?> /> <?php echo $this->translate->_("No: Do not use SMTP authentication");?>
            <br>
            <input type="radio"name="data[smtpAuthentication]" value="1" class="smtpAuthen"
            <?php echo $data['smtpAuthentication'] == '1' ? 'checked' : ''; ?>
                   <?php echo !isset($data['smtpAuthentication']) ? 'checked' : ''; ?>  /> <?php echo $this->translate->_("Yes: Use SMTP authentication");?>

            </div>
            <br style="clear:left;">
            <label class="lbl1"><?php echo $this->translate->_("Username");?>:<em> *</em></label>
	  <input name="data[smtpUsername]"
                                  class="txt1 required" id="smtpUsername"
                                  value="<?php echo $data['smtpUsername']; ?>"
                   <?php echo $data['smtpAuthentication'] == '0' ? 'disabled="true"' : ''; ?> class="txt1 required" type="text" />
          <br class="clear" />
          <label class="lbl1"><?php echo $this->translate->_("Password");?>:<em> *</em></label>
	  <input type="password"
                                  class="txt1  required" name="data[smtpPassword]"
                                  id="smtpPassword"
                                  value="<?php echo $data['smtpPassword']; ?>"
                   <?php echo $data['smtpAuthentication'] == '0' ? 'disabled="true"' : ''; ?> class="txt1 required" />
          <br class="clear" /> <br class="clear" />
          <label class="lbl1">&nbsp;</label>
          <div class="float_left button_leftb m3r">
          <div class="button_rightb"><a href="#" onclick="if(batteryObj.validateForm('data-form')) document.forms[0].submit();" ><?php echo $this->translate->_("Save");?></a></div>
        </div><div class="float_left button_leftb m3r">
          <div class="button_rightb"> <a  name="acourse" href="<?php echo $this->url(array('action' => 'loadtestform')); ?>?ajax=true&width=500&height=360" rel="prettyPhoto[ajax]"><?php echo $this->translate->_("Send test email");?></a></div>
        </div>
          <div class="float_left button_leftb">
              <div class="button_rightb"><a href="<?php echo $this->url(array("action" => "index")); ?>"><?php echo $this->translate->_("Cancel");?></a></div>
        </div>
            </form>
            </div>
            <div class="cb"></div>
        </div>
      </div>
 <script type="text/javascript">
     jQuery(document).ready(function() {
    jQuery("a[rel^='prettyPhoto']").prettyPhoto();
});
/*jQuery(function($){
});

*/  
   jQuery('#testok').click(function() {
		//alert(jQuery(this).attr('checked'));
        if(jQuery(this).attr('checked')==false)
		{
           //alert('sdas');
		   jQuery('#smtptestmail').hide();
        }
		else
		{
            jQuery('#smtptestmail').html(jQuery('#smtptestmailText').html());
            jQuery('#smtptestmail').fadeIn();
        }
    });
   jQuery('.issmtp').click(function() {
        if(jQuery(this).val() == 0){
            jQuery('#smtpContainer').fadeOut('fast', function(){
                jQuery('#smtpContainer').html('');
            });
        }else{
            jQuery('#smtpContainer').html(jQuery('#smtpContainerText').html());
            jQuery('#smtpContainer').fadeIn();
        }
    });
    jQuery('.smtpAuthen').click(function() {
        if(jQuery(this).val() == 0){
            jQuery('#smtpUsername').attr('disabled', 'true');
            jQuery('#smtpPassword').attr('disabled', 'true');
			jQuery('#smtpUsername').removeClass('required');
            jQuery('#smtpPassword').removeClass('required');
			jQuery('#smtpUsername').parent().removeClass('error');
            jQuery('#smtpPassword').parent().removeClass('error');
        }else{
            jQuery('#smtpUsername').removeAttr('disabled');
            jQuery('#smtpPassword').removeAttr('disabled');
        }
    });
    <?php //echo $data['isSmtp'] == 1? 'jQuery(\'#smtpContainer\').html(jQuery("#smtpContainerText").html());jQuery("#smtpContainer").css("display", "");':''?>


</script>
        <script type="text/javascript">
function send_test_mail()
{
	frommail=jQuery('#frommail').val();
	fromname=jQuery('#fromname').val();
	tomail=jQuery('#tomail').val();
	toname=jQuery('#toname').val();
	subject=jQuery('#subject').val();
	message=jQuery('#message').val();
	jQuery.ajax(
	{
		type: "POST",
		data: {
			'frommail': frommail,
			'fromname': fromname,
			'tomail': tomail,
			'toname': toname,
			'subject': subject,
			'message': message
			},
		dataType: 'html',
		url: "<?php echo $this->url(array('action' => 'sendtestmail')); ?>",
		success: function(result)
		{
			jQuery('#feedback').html(result);
		}
	});
}
</script>